<?php
error_reporting(E_WARNING);
include_once 'includes/metodos.php';
include_once 'includes/ini.php';
checkUser();
connectSql();

$data_atual = date("Y-m-d");
$data_anterior = date("Y-m");
$data_anterior .= '-01';

$query = mysql_query("SELECT * FROM tb_agenda WHERE status=2 AND (data BETWEEN '$data_anterior' AND '$data_atual')");
$num_falta = mysql_num_rows($query);

$query = mysql_query("SELECT * FROM tb_agenda WHERE status=4 AND (data BETWEEN '$data_anterior' AND '$data_atual')");
$num_exec = mysql_num_rows($query);

$query = mysql_query("SELECT * FROM tb_agenda WHERE status=3 AND (data BETWEEN '$data_anterior' AND '$data_atual')");
$num_des = mysql_num_rows($query);

$query = mysql_query("SELECT * FROM tb_agenda WHERE status=1 AND (data BETWEEN '$data_anterior' AND '$data_atual')");
$num_marcado = mysql_num_rows($query);
$query = mysql_query("SELECT perfil FROM tb_usuario WHERE id=".$_SESSION['id']);
$row = mysql_fetch_array($query);
include_once 'header.php';
// if($row['perfil']==1){ ?>

<body> 
<!-- Start: page-top-outer -->
<div id="page-top-outer">    

<?php include_once 'menu.php';?>
	<div id="page-heading">
		<h1>Painel</h1>
	</div>
	<!-- end page-heading -->

	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
	<tr>
		<th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
		<th class="topleft"></th>
		<td id="tbl-border-top">&nbsp;</td>
		<th class="topright"></th>
		<th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
	</tr>
	<tr>
		<td id="tbl-border-left"></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id="content-table-inner">
		
			<!--  start table-content  -->
			<div id="table-content">
				<div>
				<!-- <h2>Agenda </h2> -->
				<div style="border-radius:5px; width: 274px;  background: #F5F5F5;">
				<?php 
					if($row['perfil']==1){
						echo '<h3>Agenda</h3>';
						echo 'Total de falta nesse m&eacute;s por clientes: '.$num_falta.'<br/>';
						echo 'Total de dessistencia nesse m&eacute;s por clientes: '.$num_des.'<br/>';
						echo 'Total de cliente esperando atendimento: '.$num_marcado.'<br/>';
					}
				?>
				</div>
				<div style="border-radius:5px; width: 274px; margin-top: 5px; background: #F5F5F5;">
					<?php 
						if($row['perfil']==1){
						echo '<h3>Rel&aacute;torio de Funcionario(Mensal)</h3>';
							$query = mysql_query("SELECT * FROM tb_funcionario WHERE perfil!=4");
							while($row = mysql_fetch_array($query)){
								$sql = mysql_query("SELECT * FROM tb_agenda WHERE status=4 AND id_funcionario=".$row['id']." AND (data BETWEEN '$data_anterior' AND '$data_atual')");
								$num = mysql_num_rows($sql);
								echo '<label>'.$row['nome'].' '.$row['sobrenome'].' atendeu o total de '.$num.'</label><br/>';
							}
						}
					?>
				</div>
				</div>
				</div>
			</div>
			<!--  end table-content  -->
	
			<div class="clear"></div>
		 
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<!--  end content -->
<div class="clear">&nbsp;</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>
    
<!-- start footer -->         
<div id="footer">
<!-- <div id="footer-pad">&nbsp;</div> -->
	<!--  start footer-left -->
	<div id="footer-left">
	Admin Skin &copy; Copyright Internet Dreams Ltd. <a href="">www.netdreams.co.uk</a>. All rights reserved.</div>
	<!--  end footer-left -->
	<div class="clear">&nbsp;</div>
</div>
<!-- end footer -->
 
</body>
</html>